﻿using System;
using System.Web.UI;
using MaLu.Data;
using System.Web;

namespace MaLu.Common
{
    public class BasicPage :Page
    {
        private IDbProvider provider = null;
        protected IDbProvider Provider
        {
            get
            {
                if (provider == null)
                {
                    provider = ProviderManager.Factory.CreateDbProvider();
                    provider.Open();
                   
                }
                return provider;
            }

        }

      
        public int  Year
        {
            get
            {
                int _year = 0;
                int.TryParse(Request["year"] ?? "0", out _year);
                if (_year == 0)
                    _year = DateTime.Today.Year;
                return _year;
            }

        }
        public int Month
        {
            get
            {
                int _month = 0;
                int.TryParse(Request["month"] ?? "0", out _month);
                DateTime dt = DateTime.Now;

                if (DateTime.TryParse("2011-" + _month + "-1 0:0:0", out dt))
                {
                    return dt.Month;
                }
                else
                    return 0;
            }

        }

        public int HalfYear
        {
            get
            {
                int _h = -1;
                int.TryParse(Request["h"] ?? "-1", out _h);
                if (_h < -1 || _h > 1)
                    _h = -1;
                return _h;
            }

        }
        public int VillageID
        {
            get
            {
                int _vid = 0;
                int.TryParse(Request["vid"] ?? "0", out _vid);

                return _vid;
            }

        }
        public string Village
        {
            get
            {
                string _v =HttpUtility.UrlDecode( Request["v"] ?? string.Empty);
                if(_v=="全部")
                    _v=string.Empty;

                return _v;
            }

        }

    }
}
